//
// Created by Toosan on 2022/4/16.
//
#include "stdio.h"

/**
 * 因为C语音不支持参数重载，所以声明函数可以不用写参数
 */

void changeValue1();
//void changeValue1(int i);

void changeValue2();
//void changeValue2(int *i);

void changeValue3();
//void changeValue3(int *a, int *b);

/**
 * C语音为顺序执行，函数不能写在main()下面
 * 如果一定要写后面，需要先声明，再实现
 * @return
 */
int main4() {
    int i = 100;
    changeValue1(i);
    printf("number = %d \n", i);
    changeValue2(&i);
    printf("number = %d \n", i);
    int a = 1, b = 2;
    printf("a = %d, b = %d \n", a, b);
    changeValue3(&a, &b);
    printf("a = %d, b = %d \n", a, b);
    return 0;
}

/*
 * 此i非彼i 每个函数都会为变量开辟新的内存地址，地址不一样所以改的值也不会生效
 */
void changeValue1(int i) {
    i = 200;
}

void changeValue2(int *i) {
    *i = 200;
}

void changeValue3(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}


